<?php
/**
 * FileName: BusinessCommentConfigForm.php
 * Author: 790213952@qq.com
 * DateTime: 2024/8/26 下午7:25
 * SystemName: ym-admin
 *
 */


namespace YmPhp\Admin\Http\Forms;


use YmPhp\Admin\Models\Setting as SystemSettingModel;
use YmPhp\Admin\Widgets\Form;
use YmPhp\Admin\Layout\Row;
use YmPhp\Admin\Admin;

class BusinessCommentConfigForm extends Form
{
    /**
     * The form title.
     *
     * @var string
     */
    public $title = '基本设置';
    public $models = 'config';

    /**
     * Handle the form request.
     *
     * @param Request $request
     *
     */
    public function handle(array $input)
    {
        (new SystemSettingModel())->saveConfig($input, 'business_comment');
        return $this->response()->success('保存成功')->refresh();
    }

    /**
     * Build a form here.
     */
    public function form()
    {

        Admin::style("
            .text-capitalize {
                text-align: right;
            }
            .table td, .table th {
                border-top: 0px solid #eff1f7;
            }
            .table thead th {
                text-align: center;
            }
        ");

        $this->tab(trans('business.comment.comment_setting_name'), function () {
            $this->radio('all_ow_before_dp', __('business.comment.all_ow_before_dp'))->options(['1' => __('admin.enable'), '0' => __('admin.disable')])->default('1');
            $this->checkbox('is_models_comment', __('business.comment.is_models_comment'))->options([
                '1' => __('business.comment.models_comment_1'),
                '2' => __('business.comment.models_comment_2'),
                '3' => __('business.comment.models_comment_3'),
                '4' => __('business.comment.models_comment_4'),
                '5' => __('business.comment.models_comment_5'),
                '6' => __('business.comment.models_comment_6'),
                '7' => __('business.comment.models_comment_7'),
                '8' => __('business.comment.models_comment_8'),
                '9' => __('business.comment.models_comment_9'),
                '10' => __('business.comment.models_comment_10'),
                '11' => __('business.comment.models_comment_11'),
                '12' => __('business.comment.models_comment_12'),
            ])->default('1');

            $this->radio('allowshy', __('business.comment.allowshy'))->options(['1' => __('admin.enable'), '0' => __('admin.disable')])->default('1');
            $this->radio('allownm', __('business.comment.allownm'))->options(['1' => __('admin.enable'), '0' => __('admin.disable')])->default('1');
            $this->radio('shallowdel', __('business.comment.shallowdel'))->options(['1' => __('admin.enable'), '0' => __('admin.disable')])->default('1');
            $this->radio('is_video', __('business.comment.is_video'))->options(['1' => __('admin.enable'), '0' => __('admin.disable')])->default('1');
        });
        $this->tab(__('admin.other_config'), function () {
            $this->table('industry_rating_type', __('business.comment.industry_rating_type'),function ($table) {
                $table->text('id', __('business.comment.industry_rating_type_id'))->prepend('id');
                $table->text('key', __('business.comment.industry_rating_type_key'))->prepend('评分1');
                $table->text('value', __('business.comment.industry_rating_type_value'))->prepend('评分2');
                $table->text('desc', __('business.comment.industry_rating_type_desc'))->prepend('评分3');
            });
            $this->table('score_desc', __('business.comment.score_desc'),function ($table) {
                $table->text('id',__('business.comment.industry_rating_type_branch'))->prepend(__('business.comment.industry_rating_type_branch'));
                $table->text('name', __('business.comment.industry_rating_type_name'))->prepend(__('business.comment.industry_rating_type_name'));
                $table->color('colour', __('business.comment.industry_rating_type_colour'))->prepend(__('business.comment.industry_rating_type_colour'));
            });
            $this->list('rating_type', __('business.comment.rating_type'))->width(3);
        });
        $this->tab(trans('admin.share'), function () {
            $this->text('share_title', __('admin.share_title'));
            $this->textarea('share_desc', __('admin.share_desc'));
            $this->image('share_pic', __('admin.share_pic'))->move('upload/share/pic/')->autoUpload()->uniqueName()->saveFullUrl();
        });
    }

    /**
     * The data of the form.
     *
     * @return array $data
     */
    public function data()
    {
        $datas = SystemSettingModel::pluck('value', 'key');

        return $datas['business_comment'];
    }


}



